package com.cat.DataStructure04;

import java.util.HashSet;

class Solution05 {
    public int smallestRepunitDivByK(int k) {
        var set = new HashSet<Integer>();
        int x = 1 % k;
        while (x > 0 && set.add(x)) {
            x = (x * 10 + 1) % k;
        }
        return x > 0 ? -1 : set.size() + 1;
    }
}